{extend name='admin@main'}

{block name="content"}

{include file='store@goods/form_style'}

<form onsubmit="return false;" id="GoodsForm" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">

    <div class="layui-card-body think-box-shadow padding-left-40">

        <div class="layui-form-item layui-row layui-col-space15">
            <label class="layui-col-xs3 relative">
                <span class="color-green">文章类型</span>
                <select class="layui-select" required name="position" lay-search>
                    {foreach $positions as $position}
                    {if isset($vo.position) and $vo.position eq $position.key}
                    <option selected value="{$position.key}">{$position.text}</option>
                    {else}
                    <option value="{$position.key}">{$position.text|default=''}</option>
                    {/if}
                    {/foreach}
                </select>
            </label>
            <label class="layui-col-xs9 relative">
                <span class="color-green">文章标题</span>
                <input name="title" required class="layui-input" placeholder="请输入文章标题" value="{$vo.title|default=''}">
            </label>
        </div>

        <div class="layui-form-item block">
            <span class="label-required-prev color-green">内容</span>
            <textarea name="content">{$vo.content|default=''|raw}</textarea>
        </div>

        <div class="layui-form-item text-center">
            {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
            <button class="layui-btn layui-btn-danger" ng-click="hsitoryBack()" type="button">取消</button>
            <button class="layui-btn" type="submit">保存</button>
        </div>

    </div>
</form>
{/block}

{block name='script'}
<script>
    window.form.render();
    require(['ckeditor', 'angular'], function () {
        window.createEditor('[name="content"]', {height: 500});
        var app = angular.module("GoodsForm", []).run(callback);
        angular.bootstrap(document.getElementById(app.name), [app.name]);

        function callback($rootScope) {
            // 返回商品列表
            $rootScope.hsitoryBack = function () {
                $.msg.confirm('确定要取消吗？', function (index) {
                    history.back(), $.msg.close(index);
                });
            };
        }
    })
</script>
{/block}